﻿<%@ Page Title="" Language="C#" MasterPageFile="~/administrator/backend.Master" AutoEventWireup="true" CodeBehind="hedaotao-add.aspx.cs" Inherits="VQWEB.administrator.huongnghiep.hedaotao.hedaotao_add" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Content_backend" runat="server">
    <form id="frmObjects" action="" method="post">
    </form>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Script_backend" runat="server">
    <script type="text/javascript">
        ShowToolBar("edit");
        var url_ashx = "/admin/huongnghiep/hedaotao/handler";
        var url_input = '<%=ResolveUrl("~/administrator/templates/input.tpl") %>';

        $(document).ready(function () {
            if (CheckAtionInPath("add")) {
                loadform(0, "", "", false);
            }
            else if (CheckAtionInPath("edit")) {
                $.get(url_ashx, { view_hedaotao: "view_hedaotao", Id: GetId() }, function (data) {
                    var obj = $.parseJSON(data);
                    loadform(obj.id, obj.ten, obj.active);
                });
            }

        });

        function loadform(id, ten, active) {
            $.jqoteload(url_input, function (tmpl) {

                $("#frmObjects").single("hidden", "hedaotao_id", id, null, null, tmpl.input_tpl);
                $("#frmObjects").single("text", "hedaotao_ten", ten, "Hệ đào tạo:", null, tmpl.input_tpl);
                $("#frmObjects").single("checkbox", "hedaotao_active", true, "Kích hoạt", active, tmpl.input_tpl);
                $("#frmObjects").validate({
                    rules: { hedaotao_ten: { required: true} },
                    messages: { hedaotao_ten: { required: null} }
                });
            });

        }
               
        $(document).on("click", "#btnCancel", function () {
            window.location = "/admin/huongnghiep/hedaotao/list";
        });
        $(document).on("click", "#btnSave", function () {
            if ($("#frmObjects").valid()) {
                var arr = $("#frmObjects").serializeObject();
                $.post(url_ashx, { add_hedaotao: window.escape(arr) }, function (data) {
                    window.location = "/admin/huongnghiep/hedaotao/list";
                });
            }
        });
    </script>
</asp:Content>
